﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace WPFTestDemo
{
    public class CustomBorder : Border
    {
        private Grid _mainGrid = new Grid();

        public CustomBorder()
        {
            this.Child = _mainGrid;
        }

        /// <summary>
        /// 添加UI元素至可视化树。
        /// </summary>
        public void AddUIElementToVisualTree(UIElement element)
        {
            if (!_mainGrid.Children.Contains(element))
            {
                _mainGrid.Children.Add(element);
            }
        }

        /// <summary>
        /// 从可视化树中移除一个UI元素。
        /// </summary>
        public void RemoveUIElementFromVisualTree(UIElement element)
        {
            if (_mainGrid.Children.Contains(element))
            {
                _mainGrid.Children.Remove(element);
            }
        }
    }
}
